var CurrentIndex = 0;

function GetTotalImages()
{
	var TotalItemInput = document.getElementById('nb_total_images');
	return parseInt(TotalItemInput.value);
}

function SetNextImage()
{
	var TotalImages = GetTotalImages();

	if(CurrentIndex < TotalImages - 1)
		SetNewImage(CurrentIndex + 1);
	else
		SetNewImage(0);
}

function SetPreviousImage()
{
	var TotalImages = GetTotalImages();
	
	if(CurrentIndex > 0)
		SetNewImage(CurrentIndex - 1);
	else
		SetNewImage(TotalImages - 1);
}

function SetNewImage(NewIndex)
{
	var CurrentImage = document.getElementById('im'+CurrentIndex);
	var CurrentGauche = document.getElementById('gauche'+CurrentIndex);
	var CurrentDroite = document.getElementById('droite'+CurrentIndex);
	var NewImage = document.getElementById('im'+NewIndex);
	var NewGauche = document.getElementById('gauche'+NewIndex);
	var NewDroite = document.getElementById('droite'+NewIndex);
	
	CurrentImage.style.display = 'none';
	CurrentGauche.style.display = 'none';
	CurrentDroite.style.display = 'none';
	NewImage.style.display = 'block';
	NewGauche.style.display = 'inline-block';
	NewDroite.style.display = 'inline-block';
	
	CurrentIndex = NewIndex;
}
